$(function(){
    document.domain="lingjiuyi.cn";
    var tools={
        //取url里面参数
        getString:function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURIComponent(r[2]);
            return null;
        },
        //loading...
        setPageLoading:function (boolShowing) {
            var loading='<div class="loadImg dn" id="loadPage"><img src="/home/img/loading.svg"/></div>'
            if( $('.contWarp').find('.loadImg').length==0){
                $('.contWarp').append(loading);
            }
            $('#loadPage')[boolShowing ? 'show' : 'hide']();
            return  this;
        }
    }
    var temp={
        //content
        all_cot:'<div class="all_cot_warp">'+
        '<div class="titleWarp clearfix">'+
        '<p class="searchLabel">'+
        '<span class="active" data-classType="0">全部</span><i>|</i>'+
        '<span data-classType="1">就业课</span><i>|</i>'+
        '<span data-classType="2">职业路线</span><i>|</i>'+
        '<span data-classType="3">精品微课</span><i>|</i>'+
        '<span data-classType="4">免费微课</span><i>|</i>'+
        '<span data-classType="5">热播视频</span><i>|</i>'+
        '<span data-classType="6">会员专享</span><i>|</i>'+
        '<span data-classType="8">精彩直播</span>'+
        '</p>'+
        '</div>'+
        '<div class="contMid">'+
        '<div class="classList_warp clearfix"></div>'+
        '</div>'+
        '<div class="pages">'+
        '<div id="Pagination"></div>'+
        '</div>'+
        '</div>',
        //1：就业课；2：职业路线；3：精品微课；4：免费微课；5：免费视频；6：会员视频；7：付费视频；8：直播；
        jykTemp:
        '{{each items as $value i}}'+
        '<div class="classList_warp clearfix miniclass">'+
        '   <div class="classList">'+
        '       <div class="Info_Warp clearfix">'+
        '           <div class="classImg">'+
        '               <a href="/class/detail/?id={{$value.id}}" target="_blank">'+
        '               {{#hasImg($value.cover_img)}}</a>'+
        '           </div>'+
        '           <div class="content">'+
        '               <div class="classInfo">'+
        '                   <a href="/class/detail/?id={{$value.id}}" target="_blank">'+
        '                       <h4>' +
        '                           {{if $value.courseBelong == 1}}'+
        '                           <span>[就业课]</span>' +
        '                           {{else if $value.courseBelong == 2}}'+
        '                           <span>[职业路线]</span>' +
        '                           {{else if $value.courseBelong == 3}}'+
        '                           <span>[精品微课]</span>' +
        '                           {{else if $value.courseBelong == 4}}'+
        '                           <span>[免费微课]</span>' +
        '                           {{else if $value.courseBelong == 8}}'+
        '                           <span>[直播]</span>' +
        '                           {{else}}'+
        '                           <span>[热播]</span>' +
        '                           {{/if}}'+
        '                           {{$value.lession_name}}' +
        '                       </h4>' +
        '                   </a>'+
        '                   <p class="classIntr" title="{{$value.description}}">{{$value.description}}</p>'+
        '                   <p class="classCount">'+
        '                   {{if $value.courseBelong == 1 || $value.courseBelong == 3 || $value.courseBelong == 4}}'+
        '                       {{if $value.employmentSalary}}<span>学习人数:{{$value.studyTotal}}人</span><i>|</i>{{else}}<span>学习人数:0人</span>|{{/if}}'+
        '                       {{if $value.employmentSalary}}<span>平均薪资:{{$value.employmentSalary}}k</span><i>|</i>{{else}}<span>平均薪资:暂无</span>|{{/if}}'+
        '                       {{if $value.score}}<span>综合评分:{{$value.score}}</span><i>|</i>{{else}}<span>综合评分:暂无</span><i>|</i>{{/if}}'+
        '                       {{if $value.employmentRate}}<span>就业率:{{$value.employmentRate}}%</span><i>|</i>{{else}}<span>就业率:暂无</span><i>|</i>{{/if}}'+
        '                       <span>数据来自布丁电影网</span>'+
        '                   {{else if $value.courseBelong == 2}}'+
        '                    '+
        '                   {{else}}'+
        '                       {{if $value.employmentSalary}}<span>观看中人数:{{$value.studyTotal}}人</span><i>|</i>{{else}}<span>观看中人数:0人</span>|{{/if}}'+
        '                       {{if $value.employmentSalary}}<span>点击量:{{$value.employmentSalary}}k</span><i>|</i>{{else}}<span>点击量:暂无</span>|{{/if}}'+
        '                       {{if $value.score}}<span>综合评分:{{$value.score}}</span><i>|</i>{{else}}<span>综合评分:暂无</span><i>|</i>{{/if}}'+
        '                       {{if $value.employmentRate}}<span>评论量:{{$value.employmentRate}}%</span><i>|</i>{{else}}<span>评论量:暂无</span><i>|</i>{{/if}}'+
        '                       <span>数据来自布丁电影网</span>'+
        '                   {{/if}}'+
        '                   </p>'+
        '                   <div class="miniclass_styBtn clearfix">'+
        '                   {{if $value.courseBelong == 1 || $value.courseBelong == 3 || $value.courseBelong == 4}}'+
        '                       <div class="priceLabel">'+
        '                       {{if $value.free == "true"}}'+
        '                           <span class="currentPrice">免费</span>'+
        '                       {{else}}'+
        '                           <span class="currentPrice">￥{{$value.price}}</span>'+
        '                           <span class="originalCost">￥{{$value.del_price}}</span>'+
        '                       {{/if}}'+
        '                       </div>'+
        '                       <div class="onlineBtn">'+
        '                           {{#indexHref($value.description,$value.free,$value.id,$value.type)}}'+
        '                           查看课程</a>'+
        '                       </div>'+
        '                   {{else if $value.courseBelong == 2}}'+
        '                       <div class="onlineBtn">'+
        '                           {{#indexHref($value.description,$value.free,$value.id,$value.type)}}'+
        '                           查看路线详情</a>'+
        '                       </div>'+
        '                   {{else if $value.courseBelong == 5 || $value.courseBelong == 6 || $value.courseBelong == 7}}'+
        '                       <div class="onlineBtn">'+
        '                           {{#indexHref($value.description,$value.free,$value.id,$value.type)}}'+
        '                           立即播放</a>'+
        '                       </div>'+
        '                   {{else if $value.courseBelong == 8}}'+
        '                       <div class="onlineBtn">'+
        '                           {{#indexHref($value.description,$value.free,$value.id,$value.type)}}'+
        '                           进入直播间</a>'+
        '                       </div>'+
        '                   {{/if}}'+
        '                   </div>'+
        '               </div>'+
        '           </div>'+
        '       </div>'+
        '   </div>'+
        '</div>'+
        '{{/each}}',
        //无数据
        emptyData:'<div class="emptyCon clearfix">'+
        '<img  src="/home/img/empty.png"/>'+
        '<div class="conTxt">'+
        '<p>暂无相关内容</p>'+
        '<p>换个关键词试试吧</p>'+
        '</div>'+
        '</div>'

    }
    //论坛
    var askTemp={
        warp:'<div class="content">'+
        '<div class="ansAndQus-left-list"></div>'+
        '<div class="pagesWarp">'+
        '<div class="pages">'+
        '<div id="Pagination"></div>'+
        '</div>'+
        '</div>'+
        '</div>',
        ansAndQusLeftList:"{{each data.items as d}}" +
        "<div class='listansAndQuse'>" +
        "<div class='list-questions'>" +
        "<div class='list-questions-left'>" +
        "<div class='list-questions-left-img'>" +
        "<img src='{{d.moduleImg}}'/>" +
        "</div>" +
        "</div>" +
        "<div class='list-questions-right'>" +
        "<a href='javascript:;' class='list-questions-askModule'>【{{d.moduleName}}】</a>"+
        "<a href='/ask/qusAndAnsDetail.html?id={{d.id}}' target='_blank' class='golist' data-id='{{d.id}}'>"+
        "<span class='list-questions-right-title' title='{{#changeSeptor(d.title)}}'>{{#d.title}}</span></a>" +
        "<p class='list-questions-right-timeAndTag'>" +
        "{{each d.tag as t index}}" +
        "<span class='list-questions-right-tag' data-id='{{d.tagIds[index]}}'>{{t}}</span>" +
        "{{/each}}" +
        "<span class='list-questions-right-look' data-sum='{{d.browse_sum}}'><img src='/web/images/look.png'/>({{d.browse_sum}})</span>" +
        "<span class='list-questions-right-zan' data-sum='{{d.praise_sum}}'><img src='/web/images/zan.png'/>({{d.praise_sum}})</span>" +
        "<span class='list-questions-right-time'><img src='/web/images/time.png'/>{{d.strTime}}</span>" +
        "</p>" +
        "</div>" +
        "</div>" +
        "</div>" +
        "{{/each}}"
    }
    var boxuesTemp={
        warpTemp:'<div class="PundlitsWarp">'+
        '<div class="forum-content-info"></div>'+
        '<div class="pagesWarp">'+
        '<div class="pages">'+
        '<div id="Pagination"></div>'+
        '</div>'+
        '</div>'+
        '</div>',
        articlePaper:'{{each articlePaper as $value}}'+
        '<div class="forum-info clearfix">'+
        '<div class="forum-info-img"><a data-id="{{$value.id}}" href="javascript:;">{{#hasImg($value.img_path)}}</a></div>'+
        '<div class="forum-info-right">'+
        '<div class="forum-info-title"><a data-id="{{$value.id}}" href="javascript:;">{{#$value.title}}</a></div>'+
        '<div class="forum-info-content dot-ellipsis">{{#$value.content}}</div>'+
        '<div class="forum-info-tags">'+
        '<i class="iconfont icon-biaoqian"></i>{{#tag($value.tag,$value.tagId)}}'+
        '<span>{{$value.name}}<em></em>{{dataSubs($value.create_time)}}</span>'+
        '</div></div></div>'+
        '{{/each}}'
    }
    //论坛
    var bbsTem={
        bbsWarp:'<div class="bbsWarp">'+
        '<div class="BBSlist"></div>'+
        '<div class="pages">'+
        '<div id="Pagination"></div>'+
        '</div>'+
        '</div>',
        articlWarp:'{{each bbsList as $value }}'+
        '<div class="AticlList">'+
        '<h3 class="clearfix">'+
        '<a href="'+basePathBlog+'/{{$value.aOfTitle}}">{{$value.subject}}</a>'+
        '<span>{{$value.replies }}个回复 - {{$value.views}}次查看</span>'+
        '</h3>'+
        '<p class="aticlContent">{{$value.message}}</p>'+
        '<p class="reportData">'+
        '<span>{{$value.date}}</span>'+
        '</p>'+
        '</div>'+
        '{{/each}}'
    }
    var fromUrl=document.referrer.toLowerCase(); //判断是否是从学习空间搜索
    if(fromUrl.indexOf(basePathStudyzone)!=-1&&window.name){
        $('.searchInp input').val(window.name);
        var keyWords=window.name
        if(!searchType){
            sessionStorage.setItem('searchType',0)
        }else{
            var searchType=sessionStorage.getItem('searchType');
        }
    }else if(fromUrl.indexOf(basePathBlog)!=-1&&window.name){ //判断是否从BBS搜索
        var jsonName=JSON.parse(window.name);
        $('.searchInp input').val(jsonName.keyWords);
        var keyWords=jsonName.keyWords
        searchType=jsonName.type;
        sessionStorage.setItem('searchType',searchType)
    }else{
        $('.searchInp input').val(sessionStorage.getItem('keyword'));
        var keyWords=sessionStorage.getItem('keyword');
        searchType=sessionStorage.getItem('searchType');
    }

    var searchList={
        pageNumber:1,
        keyword:keyWords,
        searchCourseBelong:0,//默认全部 0
        pageSize:10
    };
    var parameter={
        keyword:keyWords,
        status:0,
        pageNumber:1,
        pageSize:10
    };
    var list={
        keyword:keyWords,
        pageNumber:1,
        pageSize:10
    };
    //bbs传参
    var bbsData={
        keyword:keyWords,
        pageNumber:1,
        pageSize:10
    }
    template.helper('qqchange',function(num){
        num="<p>"+num+"</p>";
        value=$(num).text()
        value=value.replace(/\s/g,"");
        return  value;
    });
    //日期时分秒只取日期
    template.helper("dataSubs",function(num){
        if(num){
            num=num.split(" ");
            return num[0]
        }
    })
    template.helper('heima', function (online_course,num) {
        var courseType = num;
        if (online_course==0){
            return ""
        }
        else{
            return "<a class='xxLine' href='"+num+"' target='_blank'>线下学习</a>"
        }
    });
    template.helper('courseTypeVar', function (num) {
        var courseType = num;
        if (courseType=="直播"){
            courseType=(courseType=="直播")?0:1;//0：直播 1：点播
        }
        else{
            courseType=(courseType=="true")?0:1;//0：直播 1：点播
        }
        return courseType;
    });
    //右侧热搜词 固定浮层
    var objTop=$('.centerWarp_right').offset().top;
    var webNotice=0;
    $(document).scroll(function(){
        if($('.webSiteNotice').css('display')=='block'){
            webNotice=$(".webSiteNotice").height();
        }else{
            webNotice=0;
        }
        var scroTop=$(document).scrollTop();
        if(scroTop>=objTop+150){
            $('.centerWarp_right').css({
                'position':'absolute',
                'top':scroTop-234-webNotice,
                'right':'0'
            })
        }else{
            $('.centerWarp_right').css({
                'position':'absolute',
                'top':'0',
                'right':'0'
            })
        }
    })

    function tabList(obj){
        obj.each(function(){
            $(this).on('click',function(){
                $(this).addClass('active').siblings().removeClass('active');
                var classType=$(this).attr('data-classType')
                searchList.searchCourseBelong=classType
                searchList.pageNumber=1
                searchClass();
            })
        })
    }
    if(searchType==0||!searchType){//默认加载
        $('.searchTitle span[data-pageType=1]').addClass('active').siblings().removeClass('active');
        $('.contWarp').html(template.compile(temp.all_cot));
        searchClass();
        tabList($('.searchLabel span'));
    }else if(searchType==1){ //论坛
        $('.searchTitle span[data-pageType=2]').addClass('active').siblings().removeClass('active');
        $('.contWarp').html(template.compile(askTemp.warp));
        ansAndQusLeft();
        $('.contentTopRight a').each(function(){
            $(this).on('click',function(){
                $(this).addClass('active').siblings().removeClass('active');
                var thisID = $(this).attr('data-id')
                parameter.status=thisID;
                parameter.pageNumber=1
                ansAndQusLeft();
            })
        })
    }else if(searchType==2){//博学社
        $('.searchTitle span[data-pageType=3]').addClass('active').siblings().removeClass('active');
        $('.contWarp').html(template.compile(boxuesTemp.warpTemp));
        paperArticle()
    }else if(searchType==3){//BBS
        $('.searchTitle span[data-pageType=4]').addClass('active').siblings().removeClass('active');
        $('.contWarp').html(template.compile(bbsTem.bbsWarp));
        bbsTemp() //论坛ajax
    }
    //一级菜单点击切换
    $('.searchTitle span').each(function(){
        $(this).click(function(){
            $(this).addClass('active ').siblings().removeClass('active');
            var pageType=$(this).attr('data-pageType');
            switch (pageType){
                case '1': //课程
                    $('.contWarp').html(template.compile(temp.all_cot));
                    sessionStorage.setItem('searchType',0)
                    searchList.searchCourseBelong=0
                    searchClass();
                    //二级菜单切换
                    tabList($('.searchLabel span'))
                    break;
                case '2': //论坛
                    template.config("escape", true);
                    $('.contWarp').html(template.compile(askTemp.warp));
                    parameter.status=0;
                    parameter.pageNumber=1;
                    sessionStorage.setItem('searchType',1)
                    ansAndQusLeft();
                    //论坛 二级菜单切换
                    $('.contentTopRight a').each(function(){
                        $(this).on('click',function(){
                            $(this).addClass('active').siblings().removeClass('active');
                            var thisID = $(this).attr('data-id')
                            parameter.status=thisID;
                            parameter.pageNumber=1
                            ansAndQusLeft();
                        })
                    })
                    break;
                case '3': //博学社
                    sessionStorage.setItem('searchType',2)
                    $('.contWarp').html(template.compile(boxuesTemp.warpTemp));
                    list.pageNumber=1
                    paperArticle()
                    break;
                case '4': //论坛
                    sessionStorage.setItem('searchType',3);
                    $('.contWarp').html(template.compile(bbsTem.bbsWarp));
                    bbsData.pageNumber=1
                    bbsTemp() //论坛ajax
                    break;
            }
        })
    })
    function serBtn(){
        if($('.searchInp input').val()==""){
            return;
        }else{
            var keyw=$('.searchInp input').val();
            sessionStorage.setItem("keyword",keyw);//更新搜索记录
            window.name="";//清空name的值,防止刷新缓存
            searchList.searchCourseBelong=0;
            searchList.keyword=keyw;
            parameter.keyword=keyw;
            list.keyword=keyw;
            bbsData.keyword=keyw;
            searchType=sessionStorage.getItem('searchType');
            if(searchType==0){ //课程
                $('.searchTitle span[data-pageType=1]').addClass('active').siblings().removeClass('active');
                $('.contWarp').html(template.compile(temp.all_cot));
                searchClass();
                //二级菜单切换
                tabList($('.searchLabel span'))
            }else if(searchType==1){ //论坛
                $('.searchTitle span[data-pageType=2]').addClass('active').siblings().removeClass('active');
                $('.contWarp').html(template.compile(askTemp.warp));
                parameter.status=0;
                ansAndQusLeft();
                //论坛 二级菜单切换
                $('.contentTopRight a').each(function(){
                    $(this).on('click',function(){
                        $(this).addClass('active').siblings().removeClass('active');
                        var thisID = $(this).attr('data-id')
                        parameter.status=thisID;
                        parameter.pageNumber=1
                        ansAndQusLeft();
                    })
                })
            }else if(searchType==2){ //博学社
                $('.searchTitle span[data-pageType=3]').addClass('active').siblings().removeClass('active');
                $('.contWarp').html(template.compile(boxuesTemp.warpTemp));
                paperArticle()
            }else if(searchType==3){//BBS
                $('.searchTitle span[data-pageType=4]').addClass('active').siblings().removeClass('active');
                $('.contWarp').html(template.compile(bbsTem.bbsWarp));
                bbsTemp() //论坛ajax
            }

        }
    }
    $('#searchBtn').click(function(){
        serBtn();
    });
    $('.searchInp input').focus(function(){
        _this=$(this)
        $('.searchInp input').addClass('focus')
    }).blur(function(){
        if(_this.val()==''){
            $('.searchInp input').removeClass('focus')
        }
    })
    $('#lgerBtn').bind('keyup',function(evt){
        if(evt.keyCode == "13"){
            serBtn();
        }
    })
    //课程
    function searchClass(){
        $('.contMid').html('');
        $(".contWarp .pages").css("display", "none");
        tools.setPageLoading(true);
        template.config("escape", false);
        //console.log(searchList);
        var parameterList = JSON.stringify(searchList);
        //console.log(parameterList);
        var newParameterList = parameterList.replace(/":"/g, '/');
        newParameterList = newParameterList.replace(/":/g, '/');
        newParameterList = newParameterList.replace(/{"/g, '/');
        newParameterList = newParameterList.replace(/","/g, '/');
        newParameterList = newParameterList.replace(/,"/g, '/');
        newParameterList = newParameterList.replace(/}/g, '');
        //console.log(newParameterList);
        RequestService('/search/courseSearch' + newParameterList,'GET',null,function(data){
            tools.setPageLoading(false);
            var res=data;
            searchList.pageNumber=1
            $('.MidTitle span').html(res.page.totalCount)
            if(res.lession ==''){
                $('.contMid').html(temp.emptyData);
                $(".contWarp .pages").css("display", "none");
            }else{
                if (res.page.totalPageCount > 1) { //分页判断
                    $(".contWarp .pages").css("display", "block");
                    if (res.page.currentPage == 1){
                        $("#Pagination").pagination(res.page.totalPageCount, {
                            callback: function (page) { //翻页功能
                                searchList.pageNumber=page+1;
                                searchClass()
                            }
                        });

                    }

                } else {
                    $(".contWarp .pages").css("display", "none");
                }
                $('.contMid').html(template.compile(temp.jykTemp)({
                    items:res.lession
                }));
                $('.classIntr').each(function(){
                    if($(this).height()>66){
                        $(this).height(66)
                    }
                    var $this=$(this);
                    function createDots() {
                        $this.dotdotdot({
                            after: 'span.qq'
                        });
                    }
                    createDots();
                })
            }

        })
    }

    //论坛
    function ansAndQusLeft(){
        tools.setPageLoading(true);
        $('.ansAndQus-left-list').html('');
        $(".pagesWarp").css("display", "none");
        RequestService("/search/askSearch",'GET',parameter,function(data){
            console.log(data)
            if(data.success){
                tools.setPageLoading(false);
                if(data.resultObject.asks.items!=''){
                    $(".pagesWarp").css("display", "block");
                    $('.ansAndQus-left-list').css('background','#ffffff');
                    $('.contentTopLeftNum').html(data.resultObject.totalAskCount);
                    $(".ansAndQus-left-list").html(template.compile(askTemp.ansAndQusLeftList)({
                        data: data.resultObject.asks
                    }));
                    //标签跳转
//	                $('.list-questions-right-tag').on('click',function(){
//	                	window.open('/ask/labelIndex.html?id='+$(this).attr('data-id'));
//	                });
                    var $dot5 = $('.dot5');
                    $dot5.each(function () {
                        if ($(this).height() > 40) {
                            $(this).attr("data-txt", $(this).attr("data-text"));
                            $(this).height(40);
                            $(this).append('<span class="qq" style="margin-right:60px"> <a class="toggle" href="###" style="color:#3492fd"><span class="opens">显示全部</span><span class="closes">收起</span></a></span>');
                        }
                        var $dot4 = $(this);

                        function createDots() {
                            $dot4.dotdotdot({
                                after: 'span.qq'
                            });
                        }

                        function destroyDots() {
                            $dot4.trigger('destroy');
                        }

                        createDots();
                        $dot4.on(
                            'click',
                            'a.toggle',
                            function () {
                                $dot4.toggleClass('opened');

                                if ($dot4.hasClass('opened')) {
                                    destroyDots();
                                } else {
                                    createDots();
                                }
                                return false;
                            }
                        );
                    });
                    if(data.resultObject.asks.totalPageCount > 1){
                        $(".pagesWarp").css("display", "block");
                        if(data.resultObject.asks.currentPage == 1) {
                            $("#Pagination").pagination(data.resultObject.asks.totalPageCount, {
                                callback: function(page) { //翻页功能
                                    parameter.status = $('.contentTopRight .active').attr('data-id')
                                    parameter.pageNumber = (page + 1);
                                    ansAndQusLeft();
                                }
                            });
                        }
                    }else{
                        $(".pagesWarp").css("display", "none");
                    }
                    $(".list-questions-right-title").parent().on("click",function(){
                        var $this = $(this)
                        RequestServiceAsk("/questionRepository/recordPV ", "POST", {id:$(this).attr("data-id")}, function (data) {
                            if(data.status==200){
                                if(data.result){
                                    var num = parseInt($this.parent().find(".list-questions-right-timeAndTag").find(".list-questions-right-look").attr("data-sum"))+1;
                                    $this.parent().find(".list-questions-right-timeAndTag").find(".list-questions-right-look").text("浏览数(" + num + ")");
                                }
                            }
                        });
                    });

                }else{
                    $('.ansAndQus-left-list').html(temp.emptyData);
                    $('.ansAndQus-left-list').css('background','none');
                    $(".pagesWarp").css("display", "none");
                    $('.contentTopLeftNum').html(data.resultObject.totalAskCount);
                }
            }
        });
    }

    //博学社
    template.helper("tag",function(tagName,tagId){
        if(tagName||tagId){
            tagName=JSON.parse(tagName);
            tagId=JSON.parse(tagId);
            var str="";
            for(var i=0;i<tagName.length;i++){
                if(i==tagName.length-1){
                    str+='<a>'+tagName[i]+'</a>';
                }else{
                    str+='<a>'+tagName[i]+'</a>'+"<span style='color:#999;margin:0 3px'>,</span>";
                }
            }
            return str;
        }
    });
    function paperArticle(){
        tools.setPageLoading(true);
        $(".forum-content-info").html('');
        $(".pages").css("display", "none");
        RequestService("/search/articleSearch",'GET',list,function(data){
            if(data.success){
                tools.setPageLoading(false);
                if(data.resultObject.articles.items.length!=0){
                    $(".forum-content-info").html(template.compile(boxuesTemp.articlePaper)({
                        articlePaper:data.resultObject.articles.items
                    }));
                    //博学社跳转
                    $(".forum-info .forum-info-title a").on('click',function(){
                        var articleId=$(this).attr("data-id");
                        RequestService("/bxs/article/updateBrowseSumById",'GET',{articleId:articleId},function(){});
                        window.open('/forum/detail.html?articleId='+articleId);
                    });
                    $(".forum-info .forum-info-img").on('click',function(){
                        var articleId=$(this).attr("data-id");
                        RequestService("/bxs/article/updateBrowseSumById",'GET',{articleId:articleId},function(){});
                        window.open('/forum/detail.html?articleId='+articleId);
                    });

                    if(data.resultObject.articles.totalPageCount > 1){
                        $(".pages").css("display", "block");
                        if(data.resultObject.articles.currentPage == 1) {
                            $("#Pagination").pagination(data.resultObject.articles.totalPageCount, {
                                callback: function(page) { //翻页功能
                                    list.pageNumber = (page + 1);
                                    paperArticle();
                                }
                            });
                        }
                    }else{
                        $(".pagesWarp").css("display", "none");
                    }
                    //省略号
                    $('.forum-info-content').dotdotdot();
                }else{
                    $('.forum-content-info').html(temp.emptyData);
                    $(".pagesWarp").css("display", "none");
                    $('.forum-content-info').css('background','none')
                }
            }

        });
    }
    //论坛
    function bbsTemp(){
        tools.setPageLoading(true);
        template.config("escape", false);
        $(".pages").css("display", "none");
        RequestService("/search/bbsSearch",'GET',bbsData,function(data){
            if(data.success){
                tools.setPageLoading(false);
                var relt=data.resultObject;
                if(relt.bbss.items.length>0){
                    $('.BBSlist').html(template.compile(bbsTem.articlWarp)({
                        bbsList:relt.bbss.items
                    }))
                    if(relt.bbss.totalPageCount > 1){
                        $(".pages").css("display", "block");
                        if(relt.bbss.currentPage == 1) {
                            $("#Pagination").pagination(relt.bbss.totalPageCount,{
                                callback: function(page) { //翻页功能
                                    bbsData.pageNumber =page + 1;
                                    bbsTemp();
                                }
                            });
                        }
                    }else{
                        $(".pages").css("display", "none");
                    }
                    $('.aticlContent').each(function(){
                        if($(this).height()>66){
                            $(this).height(66)
                        }
                        var $this=$(this);
                        function createDots() {
                            $this.dotdotdot({
                                after: 'span.qq'
                            });
                        }
                        createDots();
                    })
                }else{
                    $('.bbsWarp').html(temp.emptyData);
                }
            }
        })
    }
    //热搜词
    function hotKey(obj){
        obj.each(function(){
            var _this=$(this)
            _this.click(function(){
                var hotTxt=_this.html();
                $('#lgerBtn').val(hotTxt);
                sessionStorage.setItem('keyword',hotTxt)
                var type=sessionStorage.getItem('searchType')
                searchList.keyword=hotTxt;
                parameter.keyword=hotTxt;
                list.keyword=hotTxt;
                bbsData.keyword=hotTxt;
                window.name="";
                switch(type){
                    case "0":
                        $('.contWarp').html(template.compile(temp.all_cot));
                        searchList.searchCourseBelong=0
                        searchClass();
                        tabList($('.searchLabel span'));
                        break;
                    case "1":
                        template.config("escape", true);
                        $('.contWarp').html(template.compile(askTemp.warp));
                        parameter.status=0;
                        parameter.pageNumber=1;
                        ansAndQusLeft();
                        //论坛 二级菜单切换
                        $('.contentTopRight a').each(function(){
                            $(this).on('click',function(){
                                $(this).addClass('active').siblings().removeClass('active');
                                var thisID = $(this).attr('data-id')
                                parameter.status=thisID;
                                parameter.pageNumber=1
                                ansAndQusLeft();
                            })
                        })
                        break;
                    case "2":
                        $('.contWarp').html(template.compile(boxuesTemp.warpTemp));
                        list.pageNumber=1
                        paperArticle()
                        break;
                    case "3":
                        $('.contWarp').html(bbsTem.bbsWarp);
                        bbsData.pageNumber=1
                        bbsTemp()
                        break;
                }
            })
        })
    }
    hotKey($('.centerWarp_right p'))
})
